package com.neuedu.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.neuedu.domain.Collections;
import com.neuedu.service.ArticleService;
import com.neuedu.service.impl.ArticleServiceImpl;

/**
 * Servlet implementation class ArticleLoadIndexServlet
 */
//@WebServlet("/article/loginindex")
public class ArticleLoadIndexServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ArticleService as = new ArticleServiceImpl();
		List<Map<String, Object>> anslist = as.getAnswer();
		request.setAttribute("anslist", anslist);
		List<Map<String, Object>> hotlist = as.getHotTieByArtId();
		request.setAttribute("hotlist", hotlist);
		List<Map<String, Object>> visitlist = as.getHotVisitByArtId();
		request.setAttribute("visitlist", visitlist);
		Collections collections = new Collections();
		collections.setAnslist(anslist);
		collections.setHotlist(hotlist);
		collections.setVisitlist(visitlist);
		response.getWriter().print(JSON.toJSONString(collections));
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
